package com.ty.day5;

import java.io.File;

/**
 * Created by IntelliJ IDEA.
 *
 * @author : txy
 * @create : 2023/11/28 16:24
 */
public class FileDemo02 {
    static int count =0;
    public static void main(String[] args) {
        File file = new File("E:\\文件夹\\java");
        if (file.exists()){
            System.out.println(countFile(file));
        }else {
            System.out.println("目录都不存在，你在想什么");
        }

    }
    static Integer countFile(File file){
        Integer count =0;
        for (File f:file.listFiles()){
            if (f.isDirectory()){
                count+=countFile(f);
            }else if (f.isFile()){
                count++;
            }
        }
        return count;
    }
}
